package com.ruoyi.web.controller.system;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.LuntaiStoreApplication;
import com.ruoyi.system.service.ILuntaiStoreApplicationService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 门店申请记录Controller
 *
 * @author ruoyi
 * @date 2025-02-17
 */
@RestController
@RequestMapping("/system/storeApplication")
public class LuntaiStoreApplicationController extends BaseController
{
    @Autowired
    private ILuntaiStoreApplicationService luntaiStoreApplicationService;

    /**
     * 查询门店申请记录列表
     */
    @GetMapping("/list")
    public TableDataInfo list(LuntaiStoreApplication luntaiStoreApplication)
    {
        startPage();
        List<LuntaiStoreApplication> list = luntaiStoreApplicationService.selectLuntaiStoreApplicationList(luntaiStoreApplication);
        return getDataTable(list);
    }

    /**
     * 导出门店申请记录列表
     */
    @Log(title = "门店申请记录", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, LuntaiStoreApplication luntaiStoreApplication)
    {
        List<LuntaiStoreApplication> list = luntaiStoreApplicationService.selectLuntaiStoreApplicationList(luntaiStoreApplication);
        ExcelUtil<LuntaiStoreApplication> util = new ExcelUtil<LuntaiStoreApplication>(LuntaiStoreApplication.class);
        util.exportExcel(response, list, "门店申请记录数据");
    }

    /**
     * 获取门店申请记录详细信息
     */
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Integer id)
    {
        return success(luntaiStoreApplicationService.selectLuntaiStoreApplicationById(id));
    }

    /**
     * 新增门店申请记录
     */
    @Log(title = "门店申请记录", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    public AjaxResult add(@RequestBody LuntaiStoreApplication luntaiStoreApplication)
    {
        return toAjax(luntaiStoreApplicationService.insertLuntaiStoreApplication(luntaiStoreApplication));
    }

    /**
     * 修改门店申请记录
     */
    @Log(title = "门店申请记录", businessType = BusinessType.UPDATE)
    @PutMapping("/edit")
    public AjaxResult edit(@RequestBody LuntaiStoreApplication luntaiStoreApplication)
    {
        return toAjax(luntaiStoreApplicationService.updateLuntaiStoreApplication(luntaiStoreApplication));
    }


    /**
     * 删除门店申请记录
     */
    @Log(title = "删除门店申请记录", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Integer[] ids)
    {
        return toAjax(luntaiStoreApplicationService.deleteLuntaiStoreApplicationByIds(ids));
    }
    @PostMapping("/getAuditStatus")
    public AjaxResult getAuditStatus(@RequestParam Integer type){
        // 获取审批状态
        return AjaxResult.success(luntaiStoreApplicationService.getAuditStatus(type));
    }
    @PostMapping("/updateAuditStatus")
    public AjaxResult updateAuditStatus(@RequestParam Integer type){
        luntaiStoreApplicationService.updateAuditStatus(type);
        return AjaxResult.success("已更新");
    }
}
